<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;

class BaseRequest extends Request {

    /**
     * 重写验证失败错误格式
     */
    protected function formatErrors(Validator $validator)
    {
        return [
                   'error' => [
                       'field' => $validator->errors()->keys()[0], 
                       'message' => $validator->errors()->first()
                       ]
            ];
    }
}